package _021_11_18

func checkIsOk(subS string, allSize int, m map[string]int) bool {

	return true
}

func checkMapHave(m map[string]int, str string) bool {
	for k, _ := range m {
		if k == str {
			return true
		}
	}
	return false
}
func findSubstring(s string, words []string) []int {
	subStr := make([]string, 0)
	subStr = append(subStr, "")
	ret := make([]int, 0)
	m := make(map[string]int)
	for i := 0; i < len(words); i++ {
		m[words[i]] += 1
	}

	for i := 0; i < len(s)-len(words[0])*len(words)+1; i++ {
		num := 0
		m2 := make(map[string]int)
		for num < len(words) {
			subS := s[i+num*len(words[0]) : i+(num+1)*len(words[0])]
			if !checkMapHave(m, subS) {
				break
			}
			m2[subS] += 1
			num++
		}
		t := 0
		for k, v := range m2 {
			if m[k] != v {
				break
			}
			t++
			if t == len(m2) {
				ret = append(ret, i)
			}
		}
	}
	return ret
}
